package com.example.mystoryapp2.adapter

import android.view.View
import androidx.appcompat.widget.AppCompatTextView
import com.example.mystoryapp2.R
import com.example.mystoryapp2.domain.Page
import com.example.mystoryapp2.ui.base.BaseListAdapter
import com.example.mystoryapp2.ui.base.BaseViewHolder
import java.util.ArrayList;

class PageListAdapter(private val list: ArrayList<Page>) :
    BaseListAdapter<Page, PageListAdapter.PageViewHolder>(list) {
    class PageViewHolder(item: View) : BaseViewHolder(item) {
        val tvName: AppCompatTextView = item.findViewById(R.id.tvPageName)
        override fun getViewList(): List<View> {
            val arrayList = ArrayList<View>()
            arrayList.add(tvName)
            return arrayList
        }

    }

    override fun getLayoutId(): Int {
        return R.layout.item_page_list_layout;
    }

    override fun createViewHolder(itemView: View): PageViewHolder {
        return PageViewHolder(itemView)
    }

    override fun onBaseBindViewHolder(holder: PageViewHolder, position: Int) {
        val page = list[position]
        holder.tvName.text = page.pageName
    }
}